import SwiftUI

struct AestheticBudgetCard: View {
    let budget: Budget

    var progress: Double {
        guard budget.limit > 0 else { return 0 }
        return min(budget.spent / budget.limit, 1.0)
    }

    var progressColor: Color {
        switch progress {
        case ..<0.5: return .green
        case ..<0.85: return .yellow
        default: return .red
        }
    }

    var icon: String {
        switch budget.category {
        case "Food": return "fork.knife"
        case "Transport": return "car.fill"
        case "Shopping": return "bag.fill"
        case "Bills": return "doc.text.fill"
        case "Travel": return "airplane"
        default: return "chart.pie.fill"
        }
    }

    var body: some View {
        VStack(alignment: .leading, spacing: 14) {
            HStack {
                HStack(spacing: 10) {
                    Circle()
                        .fill(progressColor.opacity(0.15))
                        .frame(width: 44, height: 44)
                        .overlay(
                            Image(systemName: icon)
                                .font(.system(size: 20, weight: .semibold))
                                .foregroundColor(progressColor)
                        )

                    Text(budget.category)
                        .font(.headline)
                }

                Spacer()

                Text("$\(budget.spent, specifier: "%.0f") / $\(budget.limit, specifier: "%.0f")")
                    .font(.subheadline)
                    .foregroundColor(.gray)
            }

            ProgressView(value: progress)
                .tint(progressColor)
                .scaleEffect(x: 1, y: 1.2, anchor: .center)

        }
        .padding(20)
        .background(
            RoundedRectangle(cornerRadius: 22)
                .fill(Color(.systemBackground))
                .shadow(color: .black.opacity(0.05), radius: 5, y: 3)
        )
    }
}
